<?php

namespace App\Modules\Apicrzs\Http\Middleware;

use App\Traits\CryptAES;
use App\Traits\Json;
use Illuminate\Http\Request;

class ApiCheckAuth
{

    use Json;
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param
     * @return mixed
     */
    public function handle(Request $request, \Closure $next)
    {
        $token = $request->header('token');
        $user = CryptAES::decryptToken($token,'user_grzq');
        if(!$user) {
            return $this->sendApiError('请登录！', 110002);
        }
        return $next($request);
    }
}
